package top.itczw.beetl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import top.itczw.beetl.entity.User;
import top.itczw.beetl.service.UserService;

import java.util.List;

/**
 * @author czw
 */
@RestController
public class TestController {

    @RequestMapping("/")
    public ModelAndView index(){
        ModelAndView mv = new ModelAndView("/index");
        mv.addObject("name","张三");
        return mv;
    }

    @Autowired
    UserService userService;

    @RequestMapping("/getUser")
    public User getUser(int id) {
        User user = userService.findById(id);
        return user;
    }

    @RequestMapping("/selectUserAndRole")
    public List<User> selectUserAndRole() {
        return userService.selectUserAndRole();
    }

}
